import axios from "axios"
import {  showFailToast } from 'vant';



const instance1 =axios.create({
    baseURL: 'http://121.89.205.189:3000/api'
})

const list:Array<string>=[
    '/user/info',
    '/cart/add',
    '/cart/list',
    '/cart/remove'
]

instance1.interceptors.request.use(config=>{
    if(list.includes(config.url || '')){
        config.headers.token=window.localStorage.getItem('token')
    
    }
    return config
})
instance1.interceptors.response.use(res=>{
    if(res.data.code === '10019'){
        showFailToast('登录状态过期，请从新登录')
        return {}
    } 

    return res.data
})

export default instance1
